﻿ 
using SHKF.B2C.Model.Entity.Center;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace SHKF.B2C.BLL.Center
{
    public class ErpServerBLL : CenterBLL
    {
        public ErpServerBLL(SqlSugarClient db ):base(db)
        {

        }

        public ErpServerEntity SaveServer(ErpServerEntity data)
        {
            if( data.SN ==0 )
            {
               data.SN = this.db.Insertable<ErpServerEntity>(data).ExecuteReturnIdentity();
            }
            else
            {
               this.db.Updateable<ErpServerEntity>(data).ExecuteCommand();
            }

            return data;
        }

        public List<ErpServerEntity> QueryServer()
        {
            return this.db.Queryable<ErpServerEntity>().ToList();
        }

        public ErpDataBaseEntity SaveDataBase(ErpDataBaseEntity data)
        {
            if (data.SN == 0)
            {
                data.SN = this.db.Insertable<ErpDataBaseEntity>(data).ExecuteReturnIdentity();
            }
            else
            {
                this.db.Updateable<ErpDataBaseEntity>(data).ExecuteCommand();
            }

            return data;
        }

        public List<ErpDataBaseEntity> QueryDataBase(int fksn)
        {
            return this.db
                        .Queryable<ErpDataBaseEntity>()
                        .Where(ww=>ww.FKSN == fksn)
                        .ToList();
        }
    }
}
